﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Shove.Web.UI;

public partial class UserControls_News : UCBase 
{
    public UserControls_News()
    {
        Name = "商店公告";

        swpas = new ShoveWebPartAttribute[4];

        swpas[0] = new ShoveWebPartAttribute_Image("商店公告图片", "", "~/images/title_note.jpg", "显示在商店公告左边的图片");
        swpas[1] = new ShoveWebPartAttribute_Image("每条公告显示图片", "", "~/images/UserControls/point_bg.jpg", "显示在每条公告前面的图片");
        swpas[2] = new ShoveWebPartAttribute_Int("行数", "1,100", 10, "显示公告的条数");
        swpas[3] = new ShoveWebPartAttribute_Int("每行截取字数", "1,200", 10, "公告标题显示字数");
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();
        long ShopID = _Site.ID;

        dt = new DAL.Views.V_Site_Article().Open("top " + Shove._Convert.StrToInt(swpAttributes[2], 4) + " *", "isShow = 1 and ArticleTypeID = 1", "");

        if (dt != null && dt.Rows.Count > 0)
        {
            dlNew.DataSource = dt;
            dlNew.DataBind();
        }

        //imgMain.Src = this.swpAttributes[0];
    }

    protected void dlNew_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        //HtmlImage imgArrow = (HtmlImage)e.Item.FindControl("imgArrow");

        //imgArrow.Src = this.swpAttributes[1];

        HyperLink hlNews = (HyperLink)e.Item.FindControl("hlNews");
        TextBox tbID = (TextBox)e.Item.FindControl("tbID");

        hlNews.Text = Shove._String.Cut(hlNews.Text, Shove._Convert.StrToInt(this.swpAttributes[3], 10));
        hlNews.NavigateUrl = "~/Default.aspx?PN=article_details&ID=" + tbID.Text;
    }

}
